  ' extremal pdf enter alpha, alp and  integ echo sqr   from csc 8/25/91
  'from stanton jasa 77,p1358-1366, 1985, eqn 12
  
  'Q basic version, including graphics for Mac
  
  DIM b(500),Wt(500)
  
  'input is b(m) and the output is Wt(m) the extremal pdf for
  'of alpha
  
  PI = 4 *  ATN (1)
  mmax = 100
  m1 = 5
  c = 1500:'sound speed
  
 a0 = 2.03: a1=.001: a2= .79:'parameters csc fit to Ehrenbergs formula
 kr = 18.3
yfac = 10
10 PRINT" transducer pdf reduced, (ka)^2 w(b)"
 PRINT" parameters are f and re, effective radius of transducer"
 PRINT  "   Use Ehrenberg's empirical formula"
 'PRINT"old kr =";kr;" input new kr =";:INPUT kr
 PRINT"old yfac =";yfac;" input new yfac =";:INPUT yfac

' start of transducer pdf calc
 'the parameters are f and re
 'a0kr = a0/(kr)^2
 
 FOR m = 1 TO mmax
  b = m/mmax
 b(m) = b
 Wt(m) = a0*(a1 +b)^-a2
 NEXT m

    
   REM  	SCREEN DIMENSIONS
     XL = 460
     YL = 260
 
REM   	SET SCALES

 X0 = 20
     XS = (XL - X0) / b(mmax): REM  X(NM) IS MAXIMUM VALUE OF X
     Y0 = 270
     YS = 240/yfac: REM  THIS SETS THE AMPLITUDE FACTOR.
 
REM	TOOL BOX CALLS REQUIRE INTEGERS. % INDICATES INTEGER  
REM  	CALCULATE X% AND Y% AND THEN PLOT TO X1% AND Y1%.  

 CLS         : REM CLS clears the screen
 PICTURE ON  : REM PICTURE ON puts screen graphics in storage.
 SHOWPEN     : REM SHOWPEN also puts graphics on the screen 
FOR j = 0 TO 5
   FOR n = m1 TO mmax - 1
          x% =  INT (XS * b(n) + X0)
     X1% =  INT (XS * b(n+1) + X0)
          y% =  INT (Y0 - YS * Wt(n))     : REM plot + up.
          Y1% =  INT (Y0 - YS * Wt(n + 1))
         IF y% >0 AND Y1%>0 THEN LINE (x%,y%)-(X1%,Y1%)         : REM draw line
   NEXT n
NEXT j

 x% = INT (X0) : X1% = INT (XS*b(mmax) + X0)
 y% = Y0
 LINE (x%,y%) - (X1%,y%)            :REM draw axis
 LINE (x%,Y0) - (x%,Y0-2*YS)
 
 FOR n = 1 TO 10
  x% = X0
 y% = INT (Y0-YS*n*yfac/10)
 LINE (x%,y%) - (x%+2,y%)
NEXT n
 
REM	PUT TICS ON THE X-AXIS

 FOR n = 0 TO mmax STEP mmax/10
      x% =  INT (XS * b(n) + X0)
     y% = INT (Y0 )                 :REM make tics
      LINE (x%,y%+2) - (x%,y%)            :REM draw tics
     CALL MOVETO (x%-10,y%+20) : PRINT b(n);
 NEXT n
 
 CALL MOVETO (100,20) : PRINT "kr = 1  Ymax =";yfac
     
 PICTURE OFF : REM PICTURE OFF ends graphics operations.
INPUT Q$
IF Q$ = "ng" GOTO 100
 CALL MOVETO (20,280)   
   PRINT " input 'y' to make a file "
    INPUT Q$
 IF Q$ <> "y" GOTO 100

 pic$ = PICTURE$          :REM PICTURE$ is name of stored picture.
 
 CALL MOVETO (50, 25)     :REM name the file 
 PRINT  "I've got the picture in pic$ ("; LEN (pic$); ")"
 pictFile$ = FILES$ (0, "Enter name for PICT file:")
 PRINT "PICT file name is:"; pictFile$
 
REM	SAVE FILE IN 'PICT' FORMATE.

 OPEN pictFile$ FOR OUTPUT AS #1
 
REM	FOR-NEXT LOOP MAKES A HEADER FOR PICT FILE FORMATE.

 FOR I = 1 TO 512 : PRINT  #1, CHR$ (0); : NEXT
 
 PRINT  #1, pic$
 
 CLOSE  :REM the picture 'pic$' is stored as a text file.
 
REM	CHANGE THE FILE TYPE FROM TEXT TO PICT

 NAME pictFile$ AS pictFile$, "PICT"
 
REM	USE MacDraw TO READ THE FILE. THEN, 
REM	IT CAN BE SAVED AS A MacDraw DRAWING.
 
100  CLS    :REM clear screen and end

   INPUT Q$
   IF Q$ = "q" GOTO 1000
        GOTO 10

1000  END

